package com.zjm.structural.bridge.jdbc;

public class JDBCBridgeDemo {
    public static void main(String[] args) {
        System.out.println("=== JDBC桥接模式演示 ===");

        // MySQL数据库连接
        DatabaseDriver mysqlDriver = new MySQLDriver();
        DatabaseConnection mysqlConnection = new StandardConnection(
            mysqlDriver, "jdbc:mysql://localhost:3306/test", "user", "password");

        mysqlConnection.connect();
        mysqlConnection.executeQuery("SELECT * FROM users");
        mysqlConnection.close();

        System.out.println();
        System.out.println("=".repeat(100));

        // PostgreSQL数据库连接（使用连接池）
        DatabaseDriver postgresqlDriver = new PostgreSQLDriver();
        DatabaseConnection postgresqlConnection = new PooledConnection(
            postgresqlDriver, "jdbc:postgresql://localhost:5432/test", "user", "password");

        postgresqlConnection.connect();
        postgresqlConnection.executeQuery("SELECT * FROM products");
        postgresqlConnection.close();
    }
}
